package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcDemo10
{
    public static void main(String[] args)
    {
        try(Connection connection = DBUtil.getConnection())
        {
            // 静态sql 没有拼接的sql语句
            String sql = "select count(*) count from teacher";
            Statement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery(sql);
            if (resultSet.next())
            {
                System.out.println(resultSet.getInt(1));
            }
        }catch (SQLException e)
        {
            e.printStackTrace();
        }
    }
}
